/**
 * @author 太阳当空丶赵
 * @date 2022/12/1-14:58
 * @version 1.0.0
 * ExceptionHandling
 */
const result = require("../utils/result/BaseResult")
const BaseResult = require('../utils/result/BaseResult')
module.exports = (err, req, res) => {
    const {name} = err
    switch (name) {
        case 'UnauthorizedError':
            //token解析失败导致的错误
            console.info("token解析失败")
            return res.send(BaseResult.userValidateFailed())
        case 'ValidationError':
            // 参数校验失败
            console.info("参数校验失败")
            return res.send(BaseResult.validateFailed())
        default:
            res.status(err.status || 500);
            return res.send(result.error())
    }

}
